package com.luoran.bartalks.service.impl;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.luoran.bartalks.action.vo.EChartsVo;
import com.luoran.bartalks.dao.IBtEChartsVoDao;
import com.luoran.bartalks.entity.biz.BtPlanEntry;
import com.luoran.bartalks.service.IBtEChartsService;

@Service
public class BtEChartsService implements IBtEChartsService {

	@Autowired
	private IBtEChartsVoDao dao;

	@Override
	public List<EChartsVo> getPie(String dataType, String companyId, String startTime, String endTime) {
		List<EChartsVo> pie = dao.getPie(dataType, companyId, startTime, endTime);
		Iterator<EChartsVo> it = pie.iterator();
		while (it.hasNext()) {
			EChartsVo e = it.next();
			if (e.getType() == 1) {
				e.setTypeShow("运输容器");
			} else if (e.getType() == 0) {
				e.setTypeShow("仓储容器");
			} else {
				it.remove();
			}
		}
		return pie;
	}

	@Override
	public List<BtPlanEntry> getPlanEntrysBySankey(String companyId, String startTime, String endTime) {
		return dao.getPlanEntrysBySankey(companyId, startTime, endTime);
	}

	@Override
	public List<BtPlanEntry> getPlanEntrysByBar(String companyId, String startTime, String endTime) {
		return dao.getPlanEntrysByBar(companyId, startTime, endTime);
	}

	@Override
	public List<EChartsVo> getBarNumber(String startTime, String endTime, String planId) {
		return dao.getBarNumber(startTime, endTime, planId);
	}

	@Override
	public Map<String, Integer> getTitle(String companyId, String startTime, String endTime) {
		Map<String, Integer> map = new HashMap<String, Integer>();
		Integer planNumber = dao.getPlanNumber(companyId, startTime, endTime);
		Integer packingListNumber = dao.getPackingListNumber(companyId, startTime, endTime);
		Integer materielNumber = dao.getMaterielNumber(companyId, startTime, endTime);
		map.put("plan", planNumber);
		map.put("packingList", packingListNumber);
		map.put("materiel", materielNumber);
		return map;
	}

	@Override
	public List<EChartsVo> getScatter(String companyId, String startTime, String endTime) {
		return dao.getScatter(companyId, startTime, endTime);
	}

	@Override
	public List<EChartsVo> getScatterNumber(String startTime, String endTime, String positionId) {
		return dao.getScatterNumber(startTime, endTime, positionId);
	}


}
